// pages/card/my.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    TabCur:0,
    navList:['使用中','已失效'],
    page:1,
    items:[]
  },
  onLoad(options) {
    this.load();
  },
  onShow() {
    if(this.data.items.length>0){
      this.load();
    }
  },
  tabSelect(e) {
    this.setData({
      TabCur: e.currentTarget.dataset.id,
      page:1,
      items:[]
    })
    this.load();
  },
  toDetail(e){
    wx.navigateTo({
      url: '/pages/card/order_detail?id='+e.currentTarget.dataset.id,
    })
  },
  async load(){
    let res=await wx.util.post("card_order/my",{page:this.data.page,cate:this.data.TabCur});
    wx.stopPullDownRefresh();
    this.setData({
      items: res.data.data,
      page:res.data.current_page
    })
  },
  onPullDownRefresh() {
    this.load();
  },
})